import axios from '@/utils/request'

// 获取新闻列表
export const getNewsList = (id, time) => {
  return axios({
    method: 'get',
    url: '/v1_1/articles',
    params: {
      channel_id: id,
      timestamp: time,
      with_top: 1
    }
  })
}

// 对文章不喜欢
export const disLike = (target) => {
  return axios({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: { target }
  })
}

// 取消不喜欢
export const unDislike = (target) => {
  return axios({
    method: 'delete',
    url: `/v1_0/article/dislikes/${target}`
  })
}

// 举报文章
export const reportArticle = (articleId, typeId) => {
  return axios({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type: typeId
    }
  })
}

// 获取文章详情
export const getArtical = (article_id) => {
  return axios({
    method: 'get',
    url: `/v1_0/articles/${article_id}`
  })
}

// 对文章点赞
export const likings = (target) => {
  return axios({
    method: 'post',
    url: '/v1_0/article/likings',
    data: { target }
  })
}

// 取消对文章点赞
export const unLikings = (target) => {
  return axios({
    method: 'delete',
    url: `/v1_0/article/likings/${target}`
  })
}

// 获取文章评论或对评论的回复
export const getComments = (type, source, offset, limit) => {
  return axios({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type, source, offset, limit
    }
  })
}

// 发布评论或评论回复
export const putComment = (target, content, art_id) => {
  return axios({
    method: 'post',
    url: '/v1_0/comments',
    data: { target, content, art_id }
  })
}

// 对评论或评论回复点赞
export const commentLiking = (target) => {
  return axios({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: {
      target
    }
  })
}

// 取消对评论或评论回复点赞
export const unCommentLiking = (target) => {
  return axios({
    method: 'delete',
    url: `/v1_0/comment/likings/${target}`
  })
}
